import { createStore } from 'vuex'
import router from '../router/index.js'
import createPersistedStated from 'vuex-persistedstate'
/*function addNewRoute(menuList){
  console.log(menuList);
  let routes = router.options.routes
  console.log(routes)
  routes.forEach(routeItem=>{
    if(routeItem.path=="/myMenu"){
        menuList.forEach(menu=>{
            let childRoute =  {
                path:'/'+menu.menuClick,
                name:menu.menuName,
                meta:{
                    title:menu.menuName
                },
                component:()=>import('../components/'+menu.menuComponent)
            }

            routeItem.children.push(childRoute)
        })
    }
})


router.addRoute(routes)
//router.addRoutes(routes)
}*/

export default createStore({
    state: {
      // 这里是你的应用程序的状态
      menu:[]
    },
    mutations: {
      // 这里是修改状态的方法
      setMenu(state,menuList){
        state.menu = menuList
        /*addNewRoute(menuList)*/
      }
    },
    actions: {
      // 这里是触发 mutations 的方法
    },
    getters: {
      // 这里是获取状态的方法
      getMenu(state){
        return state.menu
      }
    },plugins: [createPersistedStated()]
  })
 
  